<template>

  <el-main>
    <el-form status-icon label-width="100px" class="demo-ruleForm">
      <el-form-item label="账号名称" prop="pass">
        <el-input type="password" v-model="loginForm.username" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="checkPass">
        <el-input type="password" v-model="loginForm.password" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
        <el-button @click="login()">gitee登录</el-button>
      </el-form-item>
    </el-form>
  </el-main>

</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      loginForm:{

      },
      getOauth2CodeUrl: null
    }
  },
  methods:{
    login() {
      window.location.href = this.getOauth2CodeUrl;
    }
  },
  created() {
    this.axios.get('user/user/getOauth2CodeUrl').then(res=>{
      this.getOauth2CodeUrl = res.data.msg;
    })
    let code = this.$route.query.code;
    if (code) {
      this.axios.get('user/user/login',{params: {code: code}}).then(res=>{
        //登录成功的处理逻辑
        localStorage.setItem("token", res.data.msg);
        this.$router.replace("/product")
      })
    }
  }
}
</script>

<style scoped>

</style>